import '../models/member.dart';

class PermissionManager {
  // 任务相关权限
  static bool canCreateTask(MemberRole? role) {
    return role != null && role != MemberRole.guest;
  }

  static bool canEditTask(MemberRole? role, String? taskCreatorId, String? currentUserId) {
    if (role == MemberRole.admin) return true;
    if (role == MemberRole.guest) return false;
    return taskCreatorId == currentUserId;
  }

  static bool canDeleteTask(MemberRole? role, String? taskCreatorId, String? currentUserId) {
    if (role == MemberRole.admin) return true;
    if (role == MemberRole.guest) return false;
    return taskCreatorId == currentUserId;
  }

  static bool canAssignTask(MemberRole? role) {
    return role == MemberRole.admin;
  }

  // 成员相关权限
  static bool canViewMembers(MemberRole? role) {
    return role != null;
  }

  static bool canAddMember(MemberRole? role) {
    return role == MemberRole.admin;
  }

  static bool canEditMember(MemberRole? role, String? targetMemberId, String? currentUserId) {
    if (role == MemberRole.admin) return true;
    return targetMemberId == currentUserId;
  }

  static bool canDeleteMember(MemberRole? role) {
    return role == MemberRole.admin;
  }

  // 系统设置权限
  static bool canChangeTheme(MemberRole? role) {
    return role != null;
  }

  static bool canExportData(MemberRole? role) {
    return role == MemberRole.admin;
  }

  static bool canViewAnalytics(MemberRole? role) {
    return role != null && role != MemberRole.guest;
  }

  // 通知设置权限
  static bool canManageNotifications(MemberRole? role) {
    return role != null && role != MemberRole.guest;
  }
} 